// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.radio.globals;

public final class RadioGlobalInt extends RadioGlobal<Integer> {
    public RadioGlobalInt(int value) {
        super(value, RadioGlobalType.Integer);
    }

    public RadioGlobalInt(String name, int value) {
        super(name, value, RadioGlobalType.Integer);
    }

    public int getValue() {
        return this.value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    @Override
    public String getString() {
        return this.value.toString();
    }

    @Override
    public CompareResult compare(RadioGlobal target, CompareMethod method) {
        if (target instanceof RadioGlobalInt radioGlobalInt) {
            switch (method) {
                case equals:
                    return this.value == radioGlobalInt.getValue() ? CompareResult.True : CompareResult.False;
                case notequals:
                    return this.value != radioGlobalInt.getValue() ? CompareResult.True : CompareResult.False;
                case lessthan:
                    return this.value < radioGlobalInt.getValue() ? CompareResult.True : CompareResult.False;
                case morethan:
                    return this.value > radioGlobalInt.getValue() ? CompareResult.True : CompareResult.False;
                case lessthanorequals:
                    return this.value <= radioGlobalInt.getValue() ? CompareResult.True : CompareResult.False;
                case morethanorequals:
                    return this.value >= radioGlobalInt.getValue() ? CompareResult.True : CompareResult.False;
                default:
                    return CompareResult.Invalid;
            }
        } else {
            return CompareResult.Invalid;
        }
    }

    @Override
    public boolean setValue(RadioGlobal value, EditGlobalOps operator) {
        if (value instanceof RadioGlobalInt radioGlobalInt) {
            switch (operator) {
                case set:
                    this.value = radioGlobalInt.getValue();
                    return true;
                case add:
                    this.value = this.value + radioGlobalInt.getValue();
                    return true;
                case sub:
                    this.value = this.value - radioGlobalInt.getValue();
                    return true;
            }
        }

        return false;
    }
}
